package com.libgdxbar.pvzlikegame.entities;

import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import org.libgdxbar.projects.interfaces.Clickable;
import org.libgdxbar.projects.interfaces.callback.ClickCallback;

// 可点击实体基类 请实现 onClick 方法以编写点击事件逻辑
public abstract class ClickableEntity extends RectEntity implements Clickable, ClickCallback {
	protected InputProcessor inputProcessor;
	protected boolean visible = true;

	public ClickableEntity(Rectangle rectangle) {
		super(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
		init();
	}

	public ClickableEntity(Vector2 position, Vector2 size) {
		super(position.x, position.y, size);
		init();
	}

	public ClickableEntity(float x, float y, Vector2 size) {
		super(x, y, size.x, size.y);
		init();
	}

	public ClickableEntity(float x, float y, float width, float height) {
		super(x, y, width, height);
		init();
	}

	protected void init() {
		inputProcessor = setInputListener();
	}

	/**
	 * 实现类必须声明输入处理器
	 */
	abstract protected InputProcessor setInputListener();

	@Override
	public InputProcessor getInputListener() {
		return inputProcessor;
	}
}
